package com.xiaoy.action;


import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.ExceptionMapping;
import org.apache.struts2.convention.annotation.ExceptionMappings;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.xiaoy.core.base.menu.service.MenuService;
import com.xiaoy.web.BasicAction;

@Namespace("/workspace")
@Results( {
	@Result(name = "cty", location = "/WEB-INF/content/workspace/cty.jsp", type = "dispatcher") ,
	/*@Result(name = "list", location = "/WEB-INF/content/systemexception-list.jsp", type = "dispatcher"),*/ 
	@Result(name = "error", location = "/WEB-INF/content/workspace/exception.jsp", type = "dispatcher"),
})
@ExceptionMappings( {  
    @ExceptionMapping(exception = "com.ekingwin.bas.bas.exception.SystemException", result = "error") })
public class IndexAction extends BasicAction{


//	@Resource(name="taskSimpleGenerator")
//	private TaskGenerator task ;
	
//	@Resource(name="menuService")
//	private MenuService menuService;
	
//	private String theme = "helios" ; 
//	private String ctx = request.getContextPath();
	
/**
	 * $
	 * TODO
	 */
	private static final long serialVersionUID = 1L;
	//	@Resource
//	private LoggerService service;
	@Resource
	private MenuService menuService;
	
	
	public String index()  {
		
//		service.save(null);
		try {
//			PageWrapper<Menu> menus = new PageWrapper<Menu>();
//			menuService.filterPage(menus);
//			request.setAttribute("menus", menus.getResult());
//			PageInfo pageInfo = new PageInfo();
//		
//			pageInfo.setTitle("首页");
	//		request.setAttribute("pageInfo", pageInfo);
		
	//		String username = getParameter(Templatekeys.USERNAME);
	//		setLoginUser(username);
			
//			testPortalTask();
			
			System.out.println("index");
			
			request.setAttribute("menus", menuService.getRootMenu());
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "index";
	}
	
	private void testPortalTask () {
		
//		TaskPortlet t = new TaskPortlet();
//		
//		t.setTitle("task test ");
//		t.setHeight("200");
//		t.setWidth("500");
//		task.create(t);
		
	}
	
	
	public String execute() throws Exception {
//		System.out.println("ccccc");
//		request.setAttribute("ctx", ctx);
//		request.setAttribute("theme", theme);
		
		return index();
	}
	
	
	public String cty () {
		
		System.out.println("listGird");
		return "cty";
	}

	
}
